package com.mybed.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mybed.crm.pojo.dto.CluesDto;
import com.mybed.crm.pojo.pojo.*;
import com.mybed.crm.pojo.vo.IndexStatisticsVo;
import org.apache.ibatis.annotations.*;

import java.sql.Wrapper;
import java.util.List;
import java.util.Map;

@Mapper
public interface CluesMapper extends BaseMapper<Clues> {

    IPage<Clues> selectCluesList(IPage<Clues> page1, Wrapper wrapper, @Param("CD") CluesDto cluesDto);

    IPage<Clues> selectPoolsList(IPage<Clues> page1, Object o, @Param("CD") CluesDto cluesDto);

    void insertClues(Clues clues);

    void updateClues(Clues clues);

    @Insert("insert into tb_clues_pool ( clues_id, reason, remark)  values (#{cluesId},#{reason},#{remark})")
    void setClues(CluesPool cluesPool);

    void setCluesRecord(CluesRecord cluesRecord);

    void putToBusiness(Business business);

    @Select("select * from tb_clues where id = #{clueId}")
    Clues selectCluesById(Long clueId);

    @Select("select * from tb_clues_record where clues_id = #{clueId}")
    IPage<CluesRecord> selectCluesRecordList(IPage<CluesRecord> page1, Wrapper wrapper, long clueId);


    //线索转化龙虎榜-统计总数
    Integer countAllClues(String beginCreateTime, String endCreateTime);

    //线索转化龙虎榜-统计销售人员
    @MapKey("owner")
    List<Map<String, Object>> countAllCluesSale(IndexStatisticsVo request);
}
